package cn.lili.modules.file.util;

import lombok.extern.slf4j.Slf4j;
import net.coobird.thumbnailator.Thumbnails;

import java.io.IOException;
import java.io.InputStream;

/**
 * 图片压缩
 *
 * @author liushuai(liushuai711 @ gmail.com)
 * @version v4.0
 * @Description:
 * @since 2022/11/7 17:10
 */
@Slf4j
public class ThumbnailsUtil {


    /**
     * 图片压缩
     *
     * @param inputStream 文件流
     * @return
     */
    public static void compress(InputStream inputStream, String name) {

        try {
            Thumbnails.of(inputStream).outputQuality(0.5).asBufferedImage();
        } catch (IOException e) {
            log.error("文件压缩失败:{}", name);
        }
    }


}
